package com.sport.facilities.booking.system.ui;

import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.util.Log;
import android.view.View;

import com.sport.facilities.booking.system.CancelBookingActivity;
import com.sport.facilities.booking.system.ConfirmBookingActivity;
import com.sport.facilities.booking.system.FacebookActivity;
import com.sport.facilities.booking.system.FriendListActivity;
import com.sport.facilities.booking.system.InquireBookingMadeActivity;
import com.sport.facilities.booking.system.InquireConfirmedBookingActivity;
import com.sport.facilities.booking.system.MainActivity;
import com.sport.facilities.booking.system.MakeBookingActivity;
import com.sport.facilities.booking.system.TransferBookingActivity;
import com.sport.facilities.booking.system.model.Booking;

public class MyOnClickListener implements OnClickListener,
		android.view.View.OnClickListener {
	private final int position;
	private final String TAG = "MyOnClickListener";

	public static final int CANCEL_BOOKING = 0;
	public static final int MAKE_BOOKING = 1;
	public static final int CONFIRM_BOOKING = 2;
	public static final int TRANSFER_BOOKING = 3;
	public static final int INQUIRE_BOOKING_MADE = 4;
	public static final int INQUIRE_CONFIRM_BOOKING = 5;
	public static final int NOTICE_BOARD = 6;
	public static final int FACEBOOK_EVENT = 7;
	public static final int FRIEND_LIST = 8;

	public MyOnClickListener(int position) {
		this.position = position;
	}

	public void onClick(View v) {
		// Preform a function based on the position
		// someFunction(this.position)

		// Log.d(TAG, "---" + this.position + "--- ");

		Context ctx = v.getContext();
		switch (this.position) {
		case CANCEL_BOOKING:
			Intent intent0 = new Intent(ctx, CancelBookingActivity.class);
			ctx.startActivity(intent0);
			break;
		case MAKE_BOOKING:
			Intent intent1 = new Intent(ctx, MakeBookingActivity.class);
			ctx.startActivity(intent1);
			break;
		case CONFIRM_BOOKING:
			Intent intent2 = new Intent(ctx, ConfirmBookingActivity.class);
			ctx.startActivity(intent2);
			break;
		case TRANSFER_BOOKING:
			Intent intent3 = new Intent(ctx, TransferBookingActivity.class);
			ctx.startActivity(intent3);
			break;
		case INQUIRE_BOOKING_MADE:
			Intent intent4 = new Intent(ctx,
					InquireBookingMadeActivity.class);
			ctx.startActivity(intent4);
			break;
		case INQUIRE_CONFIRM_BOOKING:
			Intent intent5 = new Intent(ctx,
					InquireConfirmedBookingActivity.class);
			ctx.startActivity(intent5);
			break;
		case NOTICE_BOARD:
			 Intent intent6 = new Intent(ctx, MainActivity.class);
			 ctx.startActivity(intent6);
			break;
		case FACEBOOK_EVENT:			
			Booking bkdetail = new Booking();
			bkdetail.setActivity("None");
			
			Intent intent7 = new Intent(ctx,
					FacebookActivity.class);
			intent7.putExtra("bookObj", bkdetail);
			ctx.startActivity(intent7);
			
			
			break;
		case FRIEND_LIST:
			Intent intent8 = new Intent(ctx, FriendListActivity.class);
			ctx.startActivity(intent8);
			break;
		default:
			break;
		}
	}

	public void onClick(DialogInterface dialog, int which) {
	}
}
